<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/2/22
 * Time: 19:44
 */

namespace app\index\controller;

use app\index\model\User as Users;
use app\index\model\UserBank;
use think\Request;

class User extends Base
{
    private $User;

    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->User = new Users();
    }

    public function index()
    {
        $key = input('get.key');
        $list = $this->User->where('nickname', 'like', "%$key%")->paginate(0,false,['query'=>request()->param()]);
        $this->assign('key', $key);
        $this->assign('data', $list);
        return $this->fetch();
    }

    public function edit()
    {
        $id = input('get.id/d');
        $list['status'] = '';
        if ($id) {
            $list = $this->User->get($id);
        }
        $this->assign('data', $list);
        return $this->fetch();
    }

    public function save()
    {
        $data = input('post.');
        $list = isset($data['id']) ? $this->User->update($data) : $this->User->insert($data);
        return $list ? resposer('操作成功', 1) : resposer('操作失败', 0);
    }

    //---------------银行列表
    public function bank()
    {
        $bank = new UserBank();
        $list = $bank->paginate();
        $this->assign('data',$list);
        return $this->fetch();
    }
}